import 'dart:collection';

import 'package:dio/dio.dart';
import 'package:tender_flutter/constant/api_path.dart';
import 'package:tender_flutter/constant/app_config.dart';
import 'package:tender_flutter/http/api_response.dart';
import 'package:tender_flutter/http/http_utils.dart';

class ApiGoods{
  /// 商品列表
  static Future getGoodsList<T>() async {
    try {
      Map<String, dynamic> params = HashMap();
      final response =
      await HttpUtils.get(ApiPath.goodsList, params: params);
      return ApiResponse<T>.completed(response);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }
  /// 商品详情
  static Future getGoods<T>({int id}) async {
    try {
      Map<String, dynamic> params = HashMap();
      params["id"] = id;
      final response =
      await HttpUtils.get(ApiPath.goodsDetail, params: params);
      return ApiResponse<T>.completed(response);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }

  /// 是否展示商城
  static Future showGoods<T>() async {
    try {
      Map<String, dynamic> params = HashMap();
      final response =
      await HttpUtils.get(ApiPath.showGoods, params: params);
      return ApiResponse<T>.completed(response);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }
}